#include<iostream>
#include<cmath>
using namespace std;
class CFraction {
private:
	int fz, fm;
public:
	CFraction(int fz_val, int fm_val);
	CFraction add(const CFraction& r);
	CFraction sub(const CFraction& r);
	CFraction mul(const CFraction& r);
	CFraction div(const CFraction& r);
	int getGCD();
	void print();
};
CFraction::CFraction(int fz_val,int fm_val) {
	fz = fz_val;
	fm = fm_val;
}
CFraction CFraction::add(const CFraction& r) {
	return CFraction(fz * r.fm + r.fz * fm, fm * r.fm);
}
CFraction CFraction::sub(const CFraction& r) {
	return CFraction(fz * r.fm - r.fz * fm, fm * r.fm);
}
CFraction CFraction::mul(const CFraction& r) {
	return CFraction(fz*r.fz, fm * r.fm);
}
CFraction CFraction::div(const CFraction& r) {
	return CFraction(fz*r.fm, fm * r.fz);
}
int CFraction::getGCD() {
	int a = abs(fz);
	int b = abs(fm);
	while (b) {
		int t = b;
		b = a % b;
		a = t;
	}
	return a;
}
void CFraction::print() {
	int r = getGCD();
	fz /= r;
	fm /= r;
	if (fz * fm < 0) {
		cout << '-';
		cout << abs(fz);
		cout << '/';
		cout << abs(fm) << endl;
	}
	else {
		cout << abs(fz);
		cout << '/';
		cout << abs(fm) << endl;
	}
}
int main()
{
	int t;
	cin >> t;
	for (int i = 0; i < t; i++) {
		int a, b;
		char p;
		cin >> a >> p >> b;
		CFraction c1(a, b);
		cin >> a >> p >> b;
		CFraction c2(a, b);
		CFraction c3 = c1.add(c2);
		c3.print();
		c3 = c1.sub(c2);
		c3.print();
		c3 = c1.mul(c2);
		c3.print();
		c3 = c1.div(c2);
		c3.print();
		cout << endl;
	}
	return 0;
}